// 主页仓库
import { like, iconList } from '@/api/index'

const state = {
   shopList: [], //商品列表数据
   iconList: [] // icon图标列表数据
}

const actions = {
   // icon图标数据
   async getIconList({ commit }) {
      // 调用接口，获取数据
      let result = await iconList()
      if (result.code === 200) {
         commit('GETICONLIST', result.iconList)
      }
   },
   // 商品列表数据
   async getShopList({ commit }) {
      // 调用接口，获取数据
      let result = await like()
      if (result.code == 200) {
         commit('GETSHOPLIST', result.like)
      }
   }
}

const mutations = {
   GETSHOPLIST(state, shopList) {
      state.shopList = shopList
   },
   GETICONLIST(state, iconList) {
      state.iconList = iconList
   }
}

const getters = {}

export default {
   actions,
   mutations,
   state,
   getters
}